-
Notifications
You must be signed in to change notification settings - Fork 218
Refined Interface of EventSource
and EventSourceManager
#597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
# Conflicts: # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/Event.java
# Conflicts: # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/DefaultEventHandler.java
…/java-operator-sdk into informer-creventsource
# Conflicts: # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/DefaultEventHandler.java
Bumps [jandex-maven-plugin](https://github.com/wildfly/jandex-maven-plugin) from 1.1.1 to 1.2.1. - [Release notes](https://github.com/wildfly/jandex-maven-plugin/releases) - [Commits](wildfly/jandex-maven-plugin@1.1.1...1.2.1) --- updated-dependencies: - dependency-name: org.jboss.jandex:jandex-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.12.4 to 4.0.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](mockito/mockito@v3.12.4...v4.0.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Pls review after this is merged: #581 |
Can you please rebase now that the informer PR has been merged? |
# Conflicts: # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/DefaultEventHandler.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/DefaultEventSourceManager.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventSource.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventSourceManager.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/internal/TimerEventSource.java # operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/DefaultEventHandlerTest.java # operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/DefaultEventSourceManagerTest.java # operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/internal/TimerEventSourceTest.java # operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/AnnotationConfiguration.java
yep, done |
private static final Logger log = LoggerFactory.getLogger(DefaultEventSourceManager.class); | ||
|
||
private final ReentrantLock lock = new ReentrantLock(); | ||
private final Map<String, EventSource> eventSources = new ConcurrentHashMap<>(); | ||
private final List<EventSource> eventSources = Collections.synchronizedList(new ArrayList<>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be a Set
, actually? We don't need the ordering but we'd rather have only one instead of the EventSource
in the collection…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
* @param eventSource the {@link EventSource} to register | ||
* @throws IllegalStateException if an {@link EventSource} with the same name is already | ||
* registered. | ||
* @throws OperatorException if an error occurred during the registration process | ||
*/ | ||
void registerEventSource(String name, EventSource eventSource) | ||
void registerEventSource(EventSource eventSource) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we also make it possible to remove an EventSource
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should not. So were thinking how to handle some dynamic registration and de-registration of event sources. But that would make sense only per custom resource. Since we want to cover events for all related custom resources which are in differenet lifecycle state. So deregistering an event source will mean that new custom resources would not receive events about related dependent resource anymore, even the custom resource was just created.
I see it rather this way: notifications for event sources about custom resource lifecycle, what we already partially cover:
- now we have
cleanupForCustomResource
when a custom resource delete, - similarly we could have an event that
customResourceCreated
. So event source could execute some related logic. Like register a webhook or etc. This would make it very general. But did not want to do it until we have some actual request. We already have for the cleanup.
* WIP * Addressing Custom Resource by Name and Namespace refactor + Informer Cache WIP * fix: DefaultEventHandler init from EventSourceManager * fix: custom resource selector test improvement * fix: wip test imrpovements * fix: test improvements * fix: further improvements * fix: build * feature: add mvn jar to gitignore * Exposing CustomResourceEventSource and informers * fix: cleanup * fix: remove caching optimization since it not possible anymore with informer * fix: formatting * refactor: make name/namespace final * feature: Simple label selector support * fix: formatting * fix: code inspection reports * fix: merge from v2 * fix: removed most deprecated apis * chore: renaming vars named k8sClient to kubernetsClient * chore(deps): bump jandex-maven-plugin from 1.1.1 to 1.2.1 (#592) Bumps [jandex-maven-plugin](https://github.com/wildfly/jandex-maven-plugin) from 1.1.1 to 1.2.1. - [Release notes](https://github.com/wildfly/jandex-maven-plugin/releases) - [Commits](wildfly/jandex-maven-plugin@1.1.1...1.2.1) --- updated-dependencies: - dependency-name: org.jboss.jandex:jandex-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump mockito-core from 3.12.4 to 4.0.0 (#591) Bumps [mockito-core](https://github.com/mockito/mockito) from 3.12.4 to 4.0.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](mockito/mockito@v3.12.4...v4.0.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feature: Build PR on v2 * chore(ci): use Java 17 * chore(ci): use only Temurin distribution * fix: Updated informer mapping to CustomResourceID * chore: add generics to PostExecutionControl to reduce IDEs noise (#594) * chore: polish the junit5 extension (#593) * fix: EventSourceManager API wip * fix: code review fixes * fix: improvements of Event Source related APIs * fix: remarks from code review Co-authored-by: Chris Laprun <[email protected]> Co-authored-by: Ioannis Canellos <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Luca Burgazzoli <[email protected]>
No description provided.